<?php
//var_dump($_SESSION);
//echo($_SESSION['admin']['username']);
//exit;
/**
 * 内容管理视图
 *
 *
 *
 */

// 保存数据框架名
$save_frame = $_SESSION[$G_admin_session_key]['save_frame'];
$back_url   = get_current_url();
// 将当前URL保存在Cookie中，避免复杂的URL字符串
cookie('back_url', strcode($back_url));
$url_cur    = get_current_url(array('orderby', 'desc'));
// 排序
$orderlist  = array('id', 'title', 'pub_date','display');
$arr_orderby= parse_orderby($orderlist, 'uid', $url_cur);


/**
 * 搜索参数处理
 *
 */
// 关键字
$key        = trim(@$_GET['key']);
// 是否包含子类
$cid    = @(int)$_GET['cid'];
$sub    = @(int)$_GET['sub'];
$chk_sub= $sub == 1 ? ' checked' : '';

$mod_url['del']='?mod=mess&action=del';

// 是否显示
$display        = @(int)$_GET['display'];
$chk_display_all= '';
$chk_display_2  = '';
$chk_display_1  = '';
if($display == 2) {
    $chk_display_2  = ' checked';
} elseif($display == 1) {
    $chk_display_1  = ' checked';
} else {
    $chk_display_all= ' checked';
}

$is_ad      = @(int)$_GET['is_ad'];
$begin_date = @$_GET['begin_date'];
$end_date   = @$_GET['end_date'];

$flag       = 0;
if(!empty($_GET['flag']) && is_array($_GET['flag'])) {
    foreach($_GET['flag'] as $f) {
        $flag += @(int)$f;
    }
}
if($cata_info['cata_type'] == 11){
$cata_keylang='通知';
}

$dsp_ad     = ($is_ad == 1) ? 'style="display:block"':'style="display:none"';
$chk_top        = @(int)$_GET['top'] == 1 ? ' checked':'';



// 预览地址
if($cata_info['cata_dir'] != '') {
    $preview    = $cata_info['cata_type'] == 1 ? '../' . $cata_info['cata_dir'] . '/index.php' : '../' . $cata_info['cata_dir'] . '/display.php';
} else {
    $preview    = '../news/display.php';
}


// + -------------------------------------- + //
// 排序处理 - 为排序加上小图标

$order_by   = @trim($_GET['orderby']);
$order_desc = @(int)$_GET['desc'];

if($order_by != '') {
    $order_desc = ($order_desc!=1) ? 'sort_asc' : 'sort_desc' ;
    $this_param_style  = $order_by . '_style';
    $$this_param_style = '<div class="' . $order_desc . '"></div>';
}

// + -------------------------------------- + //

require($abs_admin_cppath . '/header.php');

?>


<SCRIPT LANGUAGE="JavaScript" SRC="<?php echo $url_global['common'] ?>/js/popcalendar.js"></SCRIPT>
<div class="datacontainer1" id="listDiv">
<form action="<?php echo $mod_url['li'] ?>" name="search" method="get">
<div class="new_line">
	<input type="hidden" name="mod" value="<?php echo $mod ?>">
	<input type="hidden" name="action" value="<?php echo $action ?>">
	<input type="hidden" name="cata" value="<?php echo $cata ?>">

<div class="spW10 fl"></div>
<a href="<?php echo $mod_url['add'] ?>" class="btn fl">新增名录</a>

<INPUT TYPE="radio" NAME="display" id="display_all" value="0" <?php echo $chk_display_all ?>> <label for="display_all">所有</label>
<INPUT TYPE="radio" NAME="display" id="display_2" value="2" <?php echo $chk_display_2 ?>> <label for="display_2">未审</label>
<INPUT TYPE="radio" NAME="display" id="display_1" value="1" <?php echo $chk_display_1 ?>> <label for="display_1">已审</label>


	<input type="text" name="key" value="<?php echo $key?>" size="20" class="text">
	<input type="submit" value="查询" class="btn">
	
	&nbsp;&nbsp;
	<div id="clear_both"></div>
</div>
</form>

<form action="<?php echo $mod_url['del'] ?>" name="items_form" method="post" target="<?php echo $save_frame?>" onsubmit="return submit_select_items(this.name, 'item_id[]');">
<TABLE BORDER="0" CELLPADDING="4" CELLSPACING="1" width="100%" class="list_table">
<THEAD>
	<TR class="list_head">
		<TH scope=col width="30" class="textC"><a href="<?php echo $arr_orderby['id']; ?>"><?php echo $id_style;?>#</a></TH>

		<TH scope=col class="textL"><a href="<?php echo $arr_orderby['name']; ?>"><?php echo $name_style;?>标题</a></TH>
        
		<TH scope=col width="100"><a href="<?php echo $arr_orderby['pub_time']; ?>"><?php echo $pub_time_style;?>发布时间</a></TH>
		<TH scope=col width="80"><a href="<?php echo $arr_orderby['display']; ?>"><?php echo $display_style;?>审核</a></TH>
		<TH scope=col width="80">操作</TH></TR></THEAD>
<TBODY>
<?php
$tr_class   = '';
if(!empty($viewvar['record']) && sizeof($viewvar['record']) > 0) {
    foreach($viewvar['record'] as $k=>$v) {
        $tr_class   = $tr_class != 'tr0' ? 'tr0' : 'tr1';
        $id    = $v['id'];

        $article_title  = $v['name'];
        $class_info     = get_node_info($$class_var, $cid);
        $class_name     = $class_info['cname'];

        $pub_time       = $v['pub_time'];
        $pub_realname  = $v['pub_realname'];

        $createdtime    = @(int)$v['createdtime'];
        $pub_time       = date(DATE_FORMAT, $pub_time);


        $class_path      = tree_node_path_text($class_info['__node_path']);


        // 数据库中没有管html和php代码，这里过滤
        $article_title  = htmlspecialchars($article_title);
        $class_name     = htmlspecialchars($class_name);
        $pub_realname   = htmlspecialchars($pub_realname);

        $small_image  = $G_web_root . '/uploads/' . $v['small_image'];

        $article_title_cut  = zh_substr($article_title, 50);
        $class_name_cut     = zh_substr($class_name, 15);


        if($v['display'] == 1) {
            $txt_display    = "<div class=\"btn_yes\" onclick=\"listTable.toggle(this, 'display', 1, '$id')\">{$v['display']}</div>";//"<font style=\"color:#336600\">√</font>";
            //$txt_check      = '审';
        } else {
            $txt_display    = "<div class=\"btn_no\" onclick=\"listTable.toggle(this, 'display', 1, '$id')\">0</div>";//"<font style=\"color:red\">×</font>";
            //$txt_check      = "<font style=\"color:#FF0000\">审</font>";
        }


?>
	<TR class="<?php echo $tr_class; ?>" onmouseover="return chgBg(this, 1);" onmouseout="return chgBg(this, 0);">
		<TD width="30" class="textC"><input type="checkbox" value="<?php echo $id; ?>" name="item_id[]"></TD>
		<TD>&nbsp;<span title="<?php echo $article_title; ?>" onclick="listTable.edit(this, 'edit_article_title', '<?php echo $id; ?>')" style="color:<?php echo $v['tcolor'];?>"><?php echo $article_title_cut; ?></span></TD>
       
		<TD width="80" class="time01 textC"><?php echo $pub_time ?></TD>
		<TD class="textC"><?php echo $txt_display; ?></TD>
		<TD width="80" align="center">
            <a href="<?php echo $mod_url['modify']; ?>&id=<?php echo $id; ?>" class="btn_modify fl" title="修改内容">修改</a>
            <a href="<?php echo $G_web_root; ?>/admin/admin.php?mod=company&action=del&item_id=<?php echo $id; ?>" target="<?php echo $save_frame; ?>" class="btn_del fl" title="删除" onclick="return del_this();">删除</a>
		</TD></TR>
<?php
    }
} else {
?>
<TR class="tr0" onmouseover="return chgBg(this, 1);" onmouseout="return chgBg(this, 0);">
<TD colspan="10">没有或没有找到合适的记录！</td>
</td>
<?php
}
?>
</TBODY>
</TABLE>
<?php
// 分页
$page_info  = $viewvar['record_total'] . '条记录 共' . $viewvar['page_total'] . '页';
$page_list  = get_page_nav($viewvar['page_total']);
?>

<div class="page_nav">
	<div class="page_list_pre">
		<a href="javascript:void(0);" onclick="chkbox_sel_all('items_form', 'item_id[]');" class="fontB">全选</a>
		<a href="javascript:void(0);" onclick="chkbox_sel_reverse('items_form', 'item_id[]');"  class="fontB">反选</a>
	</div>
	<div class="page_list">
		<?php echo $page_list ?>
	</div>
	<div class="page_info">
		<?php echo $page_info ?>
	</div>
	<div id="clear_both"></div>
</div>

<div class="new_line">
<input type="submit" name="del" value="删除" class="btn fl">
<input type="button" name="check" value="审核" onclick="return submit_select_items(this.form.name, 'item_id[]', '通过审核', '<?php echo $mod_url['checkbatch']; ?>');" class="btn fl">
<input type="button" name="check" value="未审" onclick="return submit_select_items(this.form.name, 'item_id[]', '取消审核', '<?php echo $mod_url['uncheckbatch']; ?>');" class="btn fl">

<div class="spW10 fl"></div>
<input type="hidden" name="deltype" value="all">
		
</div>
</form>

</div>

<?php
require($abs_admin_cppath . '/footer.php');
?>